﻿@{
    ViewBag.Title = "购买记录";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@Styles.Render("~/Content/css/mineOrder")

<article class="main">
    <div class="lay">
        <nav class="mod_nav">
            <div class="lay_left">
                <a class="nav_back" onclick="turnBack()"><img src="/images/TurnBackNormal.png"></a>
                <span>购买记录</span>
            </div>
        </nav>
        <div class="MineCon">
            <nav>
                <ul>
                    <li id="list_0"><a onclick="clickOrderList(0)">全部</a></li>
                    <li id="list_1"><a onclick="clickOrderList(1)">待支付</a></li>
                    <li id="list_2"><a onclick="clickOrderList(2)">未收货</a></li>
                    <li id="list_3"><a onclick="clickOrderList(3)">已收货</a></li>
                </ul>
            </nav>
            <span id="OrderList" onscroll="orderListScroll()"></span>
            <section class="IndexWifi" style=" display:none">
                <img src="~/images/no_orderlist.png" />
                <p>还没有订单</p>
            </section>
        </div>
    </div>
</article>
<script>

    window.onload = function () {
        IsLogin();
        OrderMgr.setOrderChangeNotifyCallback(orderChangeNotifyCallback);
        var curType = OrderMgr.getOrderListCurIndex();
        $("#list_" + curType).addClass("MineNavFocus");
        OrderMgr.setOrderListCurIndex(curType);
        clickOrderList(curType);
    }

    function IsLogin() {
        if (!UserInfoMgr.isLogIn()) {
            window.location.href = '@Url.Content("~/")' + 'User/Login?url=/Order/Index';
        }
    }

    function orderChangeNotifyCallback(orderInfo) {
        var curListType = OrderMgr.getOrderListCurIndex();
        if ((OrderMgr.allOrderListType == curListType)
            || (Number(curListType) == Number(orderInfo.order_type))) {
            var orderList = OrderMgr.getOrderListCurIndex();
            getOrderListCallback(orderList);
        }
    }

    function turnBack() {
        OrderMgr.resetOrderChangeNotifyCallback();
        window.location.href = '@Url.Content("~/")' + 'User/Index';
    }

    function clickOrderList(type) {
        OrderMgr.setOrderListCurIndex(type);
        OrderMgr.getOrderList(type, 0, Number(OrderMgr.queryOrderNum), getOrderListCallback);
    }

    function getOrderListCallback(orderList) {
        if (orderList != null && (orderList.length > 0)) {
            var url = '@Url.Content("~/")' + 'Order/GetOrderList';
            NativeAjax(orderList, url, function (msg) {
                $(".IndexWifi").hide();
                $("#OrderList").show();
                loadPartialViewResult(msg, $("#OrderList"), 1);
            });
        } else {
            $(".IndexWifi").show();
            $("#OrderList").hide();
        }
    }

    function orderListScroll() {

    }
</script>
